require 'mime/types'

class Avatar < ActiveRecord::Base
  belongs_to :avatarable, :polymorphic => true

  has_attachment :content_type => :image,
    :storage => :file_system,
    :path_prefix => 'public/avatars',
    :max_size => 2.megabytes,
    :resize_to => '640x360!',
    :thumbnails => { :big =>  '200x200!', :middele => '100x100!', :small => '60x60!' }

  def swf_uploaded_data=(data)
    data.content_type = MIME::Types.type_for(data.original_filename)
    self.uploaded_data = data
  end

  validates_as_attachment
end
